home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple Macintosh CD: Powe…osh 6100/7100/8100 Series
/
Apple Macintosh CD - Power Macintosh 6100, 7100, 8100 series.7z
/
Apple Macintosh CD - Power Macintosh 6100, 7100, 8100 series.bin
/
Power Macintosh Demo Apps
/
Segue
/
DEMO
/
demo.t
< prev
next >
Wrap
Text File
|
1994-01-12
|
6KB
|
175 lines
/*
** demo.t
**
** QA Partner Demonstration using Text Editor.
**
** (For demo purposes only; testcases may not reflect optimum structure.
** Runs as is on Motif, Macintosh, and Windows).
**
** Copyright (c) 1992-1994 by Segue Software, Inc.
** All Rights Reserved.
*/
/****************************************************************************/
use "demo.inc";
main ()
{
TestAboutDialogBox ();
TestFileSave ();
TestCopyPasteCut ();
TestGotoLine ();
TestInvokeError ();
}
/*****************************************************************************/
testcase TestAboutDialogBox ()
{
// bring up About dialog box
TextEditor.Help.About.Pick (); // bring up About dialog box
VerifyValue (About.TextEditorText.GetText (), "Text Editor");
About.OK.Click () ; // close About dialog box
}
/*****************************************************************************/
testcase TestFileSave ()
{
// save a file
list of string lsText = {
"All things bright and beautiful,",
" All creatures great and small,",
"All things wise and wonderful,",
" The Lord God made them all.",
" ",
" - Cecil Frances Alexander"
};
string sFile; // determine filename by GUI type
if (GetGUIType () == GT_MOTIF) // if running on Motif,
sFile = "/tmp/temp.txt"; // set variable
else
sFile = "temp.txt";
if (SYS_FileExists (sFile)) // if the file exists,
SYS_RemoveFile (sFile); // remove it
TextEditor.Document.SetMultiText (lsText); // write in some text
TextEditor.File.Save.Pick (); // bring up the save dialog box
SaveAs.FileName.SetText (sFile); // write the filename
SaveAs.OK.Click (); // save the file
TextEditor.File.Open.Pick (); // bring up the open dialog box
if (GetGUIType () == GT_MOTIF) { // if running on Motif,
Open.Filter.SetText ("/tmp/*.txt"); // set the filter
Open.FilterButton.Click (); // push the filter button
Open.FileName.SetText (sFile); // file to open
}
Open.Files.Select (sFile); // select the file
Open.OK.Click (); // click OK
VerifyValue (TextEditor.Document.GetMultiText (), lsText); // test that it is correct
TextEditor.File.New.Pick (); // clean up edit field
}
/*****************************************************************************/
testcase TestCopyPasteCut ()
{
// copy, paste, and cut some text
list of string lsText = {
"Kiss me you fool,",
"before the lava",
"hits the village!"
};
TextEditor.Document.SetMultiText (lsText); // write the text
TextEditor.Document.TypeKeys ("<Up 2>"); // move up 2 lines
TextEditor.Document.TypeKeys ("<Shift-Left 20>"); // highlight the line
TextEditor.Edit.Copy.Pick (); // copy text to clipboard
TextEditor.Document.Click (); // deselect highlighted text
TextEditor.Document.TypeKeys ("<Right 17>"); // move to end of line
TextEditor.Document.TypeKeys ("<Enter>"); // move cursor to next line
TextEditor.Edit.Paste.Pick (); // paste in the text
VerifyValue (TextEditor.Document.GetMultiText (2,1), {"Kiss me you fool,"});
TextEditor.Document.TypeKeys ("<Up 1>"); // move up one line
TextEditor.Document.TypeKeys ("<Shift-Left 10>"); // highlight some text
TextEditor.Edit.Cut.Pick (); // cut out selected text
VerifyValue (TextEditor.Document.GetMultiText (1,1), {"Kiss me"});
TextEditor.File.New.Pick (); // return app to base state
MessageBox.No.Click (); // don't save changes
}
/*****************************************************************************/
testcase TestGotoLine ()
{
// move cursor to specific lines
list of string lsText = {
"Nothing can bring you peace",
"but yourself.",
"Nothing can bring you peace",
"but the triumph of principles.",
" ",
" - Self-Reliance, R. W. Emerson"
};
TextEditor.Document.SetMultiText (lsText); // write text
TextEditor.Search.GotoLine.Pick (); // bring up goto dialog box
GotoLine.Line.SetText ("4"); // go to line # 4
GotoLine.OK.Click (); // push OK button
TextEditor.Document.TypeKeys ("<Shift-Right 30>"); // highlight the line
VerifyValue (TextEditor.Document.GetSelText (), "but the triumph of principles.");
TextEditor.Document.Click (); // deselect text
TextEditor.Search.GotoLine.Pick (); // bring up Go To dialog box
GotoLine.Line.SetText ("2"); // go to line # 1
GotoLine.OK.Click (); // push OK button
TextEditor.Document.TypeKeys ("<Shift-Right 13>"); // highlight the line
VerifyValue (TextEditor.Document.GetSelText (), "but yourself.");
TextEditor.File.New.Pick (); // try to create a new file
MessageBox.No.Click (); // don't save file
}
/*****************************************************************************/
testcase TestInvokeError ()
{
// intentionall invoke an error
string sText = "We hope you enjoyed our demo!";
TextEditor.Document.SetText (sText);
VerifyValue (TextEditor.Document.GetText (), "We hope you enjoyed our {GUI_GetName ()} demo!");
TextEditor.File.New.Pick ();
MessageBox.No.Click ();
}